<?php
	session_start();
	if(!isset($_SESSION["jara_admin"])) {
		header("Location: ../login.php");
		exit;
	}
	require_once("../include/templating_fns.php");
	require_once("../include/db_fns.php");
	jara_page_start("Overview - Administrator CP");
	$num_categories = 1;
?>
<h2>Overview</h2>
<p>
<?php
	if($_SESSION["jara_permissions"][0] == 1) {
		$result = jara_db_query("select * from jara_posts");
		echo "<strong>".$result->num_rows."</strong> post".(($result->num_rows == 1) ? "" : "s");
		$result = jara_db_query("select * from jara_categories");
		echo " in <strong>".$result->num_rows."</strong> categor".(($result->num_rows == 1) ? "y" : "ies");
		$num_categories = $result->num_rows;
		echo "<br />";
	}
	if($_SESSION["jara_permissions"][1] == 1) {
		$result = jara_db_query("select * from jara_pages");
		echo "<strong>".$result->num_rows."</strong> page".(($result->num_rows == 1) ? "" : "s")."<br />";
	}
	if($_SESSION["jara_permissions"][2] == 1) {
		$result = jara_db_query("select * from jara_users");
		echo "<strong>".$result->num_rows."</strong> administrator".(($result->num_rows == 1) ? "" : "s")."<br />";
	}
	if($_SESSION["jara_permissions"][3] == 1) {
		$v = count(scandir("./../uploads/"))-2;
		echo "<strong>$v</strong> uploaded file".(($v == 1) ? "" : "s")."<br />";
	}
	if($_SESSION["jara_permissions"][0] == 1) {
		$result = jara_db_query("select * from jara_comments");
		echo "<strong>".$result->num_rows."</strong> comment".(($result->num_rows == 1) ? "" : "s");
	}
?>
</p>
<p>
	<strong>Quick Links</strong><br />
<?php
	if($_SESSION["jara_permissions"][0] == 1) {
?>
	<a href="write_post.php">Write Post</a><br />
<?php
	}
	if($_SESSION["jara_permissions"][2] == 1) {
?>
	<a href="add_user.php">Add User</a><br />
<?php
	}
?>
	<a href="../search.php">Search Blog</a>
<p>
	<strong>Actions</strong><br />
<?php
	if($_SESSION["jara_permissions"][0] == 1) {
?>
	<?php if($num_categories == 1) { ?><em>You haven't got any categories. Why not <a href="add_category.php">add one</a> and start organizing your blog posts?<br /></em><?php } ?>
	<a href="posts.php"><img src="images/jara_posts.png" alt="Posts Icon" style="border: none; outline: none" border="0" />&nbsp;Manage Posts</a><br />
	<a href="comments.php"><img src="images/jara_comments.png" alt="Comments Icon" style="border: none; outline: none" border="0" />&nbsp;Manage Comments</a><br />
	<a href="categories.php"><img src="images/jara_categories.png" alt="Categories Icon" style="border: none; outline: none" border="0" />&nbsp;Manage Categories</a><br />
<?php
	}
?>
<?php
	if($_SESSION["jara_permissions"][1] == 1) {
?>
	<a href="pages.php"><img src="images/jara_pages.png" alt="Pages Icon" style="border: none; outline: none" border="0" />&nbsp;Manage Pages</a><br />
<?php
	}
	if($_SESSION["jara_permissions"][3] == 1) {
?>
	<a href="upload.php"><img src="images/jara_upload.png" alt="Upload Icon" style="border: none; outline: none" border="0" />&nbsp;Upload a File</a><br />
<?php
	}
?>
<?php
	if($_SESSION["jara_permissions"][2] == 1) {
?>
	<a href="users.php"><img src="images/jara_users.png" alt="Users Icon" style="border: none; outline: none" border="0" />&nbsp;Manage Users</a><br />
	<a href="choose_template.php">Choose Template</a><br />
	<a href="choose_widgets.php">Choose Widgets</a><br />
<?php
	}
?>
	<a href="change_password.php">Change My Password</a><br />
	<a href="logout.php">Logout</a>
</p>
<?php
	jara_page_end();
	exit;
?>